package com.example.bgdharaniPlayer.model;

import java.util.ArrayList;
import java.util.List;

/**
 * 播放列表模型类，管理音频轨道集合
 */
public class Playlist {
    private String id;
    private String name;
    private List<AudioTrack> tracks;
    private int order; // 播放列表排序顺序

    public Playlist(String name) {
        this.id = String.valueOf(System.currentTimeMillis());
        this.name = name;
        this.tracks = new ArrayList<>();
        this.order = 0; // 默认顺序为0
    }
    
    public Playlist(String id, String name) {
        this.id = id;
        this.name = name;
        this.tracks = new ArrayList<>();
        this.order = 0; // 默认顺序为0
    }
    
    public int getOrder() {
        return order;
    }
    
    public void setOrder(int order) {
        this.order = order;
    }
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<AudioTrack> getTracks() {
        return tracks;
    }

    public void setTracks(List<AudioTrack> tracks) {
        this.tracks = tracks;
    }

    public void addTrack(AudioTrack track) {
        tracks.add(track);
    }

    public void removeTrack(AudioTrack track) {
        tracks.remove(track);
    }

    public void removeTrack(int position) {
        if (position >= 0 && position < tracks.size()) {
            tracks.remove(position);
        }
    }

    public AudioTrack getTrack(int position) {
        if (position >= 0 && position < tracks.size()) {
            return tracks.get(position);
        }
        return null;
    }

    public int size() {
        return tracks.size();
    }

    public boolean isEmpty() {
        return tracks.isEmpty();
    }
}